package com.cynteka.cyfoman.core.config;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * User: Sergey
 * Date: 28.07.11
 * Time: 15:58
 */
@XmlRootElement
public class CollectionMD {
    private String crossTable;
    private String referenceToField;
    private String referenceFromField;
    private String sql;

    @XmlElement
    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    @XmlElement
    public String getCrossTable() {
        return crossTable;
    }

    public void setCrossTable(String crossTable) {
        this.crossTable = crossTable;
    }

    @XmlElement
    public String getReferenceToField() {
        return referenceToField;
    }

    public void setReferenceToField(String referenceToField) {
        this.referenceToField = referenceToField;
    }

    @XmlElement
    public String getReferenceFromField() {
        return referenceFromField;
    }

    public void setReferenceFromField(String referenceFromField) {
        this.referenceFromField = referenceFromField;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CollectionMD that = (CollectionMD) o;

        if (crossTable != null ? !crossTable.equals(that.crossTable) : that.crossTable != null) return false;
        if (referenceFromField != null ? !referenceFromField.equals(that.referenceFromField) : that.referenceFromField != null)
            return false;
        if (referenceToField != null ? !referenceToField.equals(that.referenceToField) : that.referenceToField != null)
            return false;
        if (sql != null ? !sql.equals(that.sql) : that.sql != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = crossTable != null ? crossTable.hashCode() : 0;
        result = 31 * result + (referenceToField != null ? referenceToField.hashCode() : 0);
        result = 31 * result + (referenceFromField != null ? referenceFromField.hashCode() : 0);
        result = 31 * result + (sql != null ? sql.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "CollectionMD{" +
                "crossTable='" + crossTable + '\'' +
                ", referenceToField='" + referenceToField + '\'' +
                ", referenceFromField='" + referenceFromField + '\'' +
                ", sql='" + sql + '\'' +
                '}';
    }
}
